//
//  HandlerManager.h
//  xyz
//
//  Created by jorsun on 14-3-14.
//
//

#ifndef __xyz__HandlerManager__
#define __xyz__HandlerManager__

#include <iostream>
#include "cocos2d.h"
#include "BaseHandler.h"
#include <list>
#include <map>
#include "MessageCode.h"
#include "LoginHandler.h"
#include "BattleHandler.h"
using namespace std;
class HandlerManager{
public:
    ~HandlerManager();
	static HandlerManager* getInstance();
    virtual void init();
	/**
	 * ×¢²áIMessageHandler
	 *
	 * @param handler
	 * @throws IllegalStateException
	 *             µ±ÖØ¸´×¢²áÍ¬Ò»ÏûÏ¢µÄÀàÐÍµÄ´¦ÀíÆ÷Ê±»áÅ×³ö´ËÒì³£
	 * @throws IllegalArgumentException
	 *             handlerÎª¿ÕÊ±
	 *
	 */
    virtual void addHandler(BaseHandler* handler);
    virtual void execute(BaseMessage* message);
private:
    map<short, BaseHandler*> handlers;
	HandlerManager();
    
};
#endif /* defined(__xyz__HandlerManager__) */
